import Vue from 'vue'
import Router from 'vue-router'
import home from '@/components/home/home'
import label from '@/components/label/label'
import files from '@/components/files/files'
import messageBoard from '@/components/messageBoard/messageBoard'
import interlinkage from '@/components/interlinkage/interlinkage'
import booklist from '@/components/booklist/booklist'
import about from '@/components/about/about'
import project from '@/components/project/project'
import rss from '@/components/rss/rss'
import search from '@/components/search/search'
import login from '@/components/personal/login/login'
import register from '@/components/personal/login/Register'
import forgetPass from '@/components/personal/login/forgetPass'
import personalTabbar from '@/components/personal/personal/personalTabbar.vue'
import updateMes from '@/components/personal/personal/updateMes'
import personal from '@/components/personal/personal/personal'
import aboutMe from '@/components/personal/personal/aboutMe'
import account from '@/components/personal/personal/account'
import logout from '@/components/personal/personal/logout'
import collect from '@/components/personal/personal/collect'
import praise from '@/components/personal/personal/praise'
import details from '@/components/home/details'
import exploitation from '@/components/home/exploitation'
import snailReading from '@/components/home/snailReading'
import element from '@/components/home/element'
import labelList from '@/components/label/labelList'
import labelDetail from '@/components/label/labelDetail'
// 后台管理系统
import backend from '@/components/backend/backend'
import welcome from '@/components/backend/welcome'
import editUser from '@/components/backend/editUser'
import setLevel from '@/components/backend/setLevel'
import editTags from '@/components/backend/editTags'
import editPost from '@/components/backend/editPost'
import editCategory from '@/components/backend/editCategory'
import editComments from '@/components/backend/editComments'
import unreadComments from '@/components/backend/unreadComments'
Vue.use(Router)

// vue路由解决Uncaught (in promise) Error: Avoided redundant navigation to current location: “/home/news“.
//import HelloWorld from '@/components/HelloWorld'
const originalPush = Router.prototype.push
  Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: home,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/details',
      name: 'details',
      component: details,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/exploitation',
      name: 'exploitation',
      component: exploitation,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/snailReading',
      name: 'snailReading',
      component: snailReading,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/element',
      name: 'element',
      component: element,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/label',
      name: 'label',
      component: label,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/labelList',
      name: 'labelList',
      component: labelList,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/labelDetail',
      name: 'labelDetail',
      component: labelDetail,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/files',
      name: 'files',
      component: files,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/messageBoard',
      name: 'messageBoard',
      component: messageBoard,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/interlinkage',
      name: 'interlinkage',
      component: interlinkage,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/booklist',
      name: 'booklist',
      component: booklist,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/about',
      name: 'about',
      component: about,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/project',
      name: 'project',
      component: project,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/rss',
      name: 'rss',
      component: rss,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/backend',
      name: 'backend',
      component: backend,
      meta:{
        tt:false,
        index:1
      },
      redirect:'/welcome',
      children:[
        {path:'/welcome',component:welcome},
        {path:'/editUser',component:editUser},
        {path:'/setLevel',component:setLevel},
        {path:'/editTags',component:editTags},
        {path:'/editCategory',component:editCategory},
        {path:'/editPost',component:editPost},
        {path:'/editComments',component:editComments},
        {path:'/unreadComments',component:unreadComments}
      ]
    },
    {
      path: '/search',
      name: 'search',
      component: search,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/login',
      name: 'login',
      component: login,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/forgetPass',
      name: 'forgetPass',
      component: forgetPass,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/register',
      name: 'register',
      component: register,
      meta:{
        tt:true,
        index:0
      }
    },
    {
      path: '/personalTabbar',
      name: 'personalTabbar',
      component: personalTabbar,
      meta:{
        tt:true,
        index:0
      },
      children:[
        {
          path:'/personalTabbar',
          redirect:'personal',

        },
        {
          path:'personal',
          component:personal,
          meta:{
            tt:true,
            index:0
          }
        },
        {
          path:'updateMes',
          component:updateMes,
          meta:{
            tt:true,
            index:0
          }
        },
        {
          path:'aboutMe',
          component:aboutMe,
          meta:{
            tt:true,
            index:0
          }
        },
        {
          path:'account',
          component:account,
          meta:{
            tt:true,
            index:0
          }
        },
        {
          path:'logout',
          component:logout,
          meta:{
            tt:true,
            index:0
          }
        },
        {
          path:'collect',
          component:collect,
          meta:{
            tt:true,
            index:0
          }
        },
        {
          path:'praise',
          component:praise,
          meta:{
            tt:true,
            index:0
          }
        },

      ]
    },
  ]
})
